package com.dkts.oil.router.param;

import com.alibaba.fastjson.JSONArray;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.locationtech.jts.geom.Coordinate;
import org.opengis.style.LineSymbolizer;

import java.util.List;

@Data
@Schema(description = "路径规划信息")
public class PipelineRouterInfo {


    @Schema(description = "传入的名称",example = "转运站到储备库")
    private String name;


    @Schema(description = "路线规划的点集合")
    private PathLineInfo paths;

    public PipelineRouterInfo(){}

    public PipelineRouterInfo(String name, PathLineInfo paths) {
        this.name = name;
        this.paths = paths;
    }

    @Schema(description = "路径信息")
    @Data
    public static class PathLineInfo {
        @Schema(description = "距离 单位米")
        private Double distance;

        @Schema(description = "路径点信息")
        private RouteLinePoints roadInfos;

    }
    @Schema(description = "路径点信息")
    @Data
    public static class RouteLinePoints {
        @Schema(description = "类型：LingString")
        private String type;

        @Schema(description = "经纬度信息")
        private JSONArray coordinates;

        public RouteLinePoints() {
            this.type = "LineString";
        }

        public RouteLinePoints(JSONArray coordinates) {
            this.type = "LineString";
            this.coordinates = coordinates;
        }

        public RouteLinePoints(List<Coordinate> coordinates) {
            this.type = "LineString";
            JSONArray jsonArray = new JSONArray(1024);
            for (Coordinate coordinate : coordinates) {
                JSONArray jsonArray1 = new JSONArray(4);
                jsonArray1.add(coordinate.getX());
                jsonArray1.add(coordinate.getY());
                jsonArray.add(jsonArray1);
            }
            this.coordinates = jsonArray;
        }

    }

}
